/*
 * File: ReplacementShaderEffect.cs
 * -----
 * Description: 
 * -----
 * Created  By: Aim 2021-07-01 21:31:36
 * Modified By: Aim 2021-07-02 10:55:37
 * -----
 * HISTORY:
 * Date      	By	Comments
 * ----------	---	----------------------------------------------------------
 */


using UnityEngine;

[ExecuteInEditMode]
public class ReplacementShaderEffect : MonoBehaviour
{
    public Shader ReplacementShader;
    public Color m_Color;

    public Texture2D FirstTexture;
    public Texture2D SecondaryTexture;

    void OnValidate()
    {
        // Shader.SetGlobalColor("_OverDrawColor", m_Color);

        Shader.SetGlobalTexture("_FirstTex", FirstTexture);
        Shader.SetGlobalTexture("_SecondaryTex", SecondaryTexture);
    }

    private void OnEnable()
    {
        if (ReplacementShader != null)
            GetComponent<Camera>().SetReplacementShader(ReplacementShader, "RenderType");
    }

    private void OnDisable()
    {
        GetComponent<Camera>().ResetReplacementShader();
    }
}